<?php

namespace App\Controllers;

class Mail extends BaseController
{
    /**
     * @var \CodeIgniter\Email\Email
     */
    private $email;
    private $protocol = 'smtp';
    private $SMTPHost = 'smtp.163.com';
    private $SMTPUser = 'celiachu207@163.com';
    private $SMTPPass = 'WUNCCCWZIQQBJMVO';
    private $code = 'WUNCCCWZIQQBJMVO';

    public function __construct()
    {
        parent::__construct();
        $this->email = \Config\Services::email();
    }

    public function send_mail($to, $subject, $content)
    {
        try{
            $this->email->setFrom('celiachu207@163.com', 'blog');
            $this->email->setTo($to);

            $this->email->setSubject($subject);
            $this->email->setMessage($content);
            return $this->email->send();
        }
        catch (\Exception $exception){
            return  $this->email->printDebugger(['headers']);
        }

    }
}